package day16;

public class SyncDemo {
    public static void main(String[] args) {
        Bank bank = new Bank();
        //创建线程,模拟两个人取同一个账户的钱
        Thread p1 = new Thread(new P1(bank));
        Thread p2 = new Thread(new P2(bank));
        p1.start();
        p2.start();
    }
}

class P1 implements Runnable {
    Bank bank;

    P1(Bank bank) {
        this.bank = bank;
    }
    public void run() {
        bank.getMoney(10000);
    }
}

class P2 implements Runnable {
    Bank bank;

    P2(Bank bank) {
        this.bank = bank;
    }
    public void run() {
        bank.getMoney(10000);
    }
}

